package com.jixiang.goods.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jixiang.goods.dao.GsGoodsBrankDao;
import com.jixiang.goods.service.GsGoodsInfoService;
import com.jixiang.model.common.dtos.ResponseResult;
import com.jixiang.model.goods.entity.GsGoodsBrank;
import com.jixiang.goods.service.GsGoodsBrankService;
import com.jixiang.model.goods.entity.GsGoodsInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (GsGoodsBrank)表服务实现类
 *
 * @author makejava
 * @since 2023-10-21 16:44:03
 */
@Service("gsGoodsBrankService")
public class GsGoodsBrankServiceImpl extends ServiceImpl<GsGoodsBrankDao, GsGoodsBrank> implements GsGoodsBrankService {
    @Resource
    private GsGoodsInfoService gsGoodsInfoService;
    @Override
    public ResponseResult addGoodsBrank(GsGoodsBrank gsGoodsBrank) {
        boolean save = save(gsGoodsBrank);
        return ResponseResult.okResult("添加成功");
    }

    @Override
    public ResponseResult delGoodsBrankById(String id) {
        List<GsGoodsInfo> list = gsGoodsInfoService.query().eq("goods_brank_id",id).list();
        if(!list.isEmpty()){
            return ResponseResult.errorResult(500,"该品牌存在商品数据无法删除");
        }
        boolean b = removeById(id);
        return ResponseResult.okResult("删除成功");
    }
}

